package cemp.kafka;

import cemp.common.util.DateUtil;
import cemp.common.util.DateUtils;
import cemp.config.InfluxDBUtils;
import cemp.redis.util.RedisUtils;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import static cemp.common.constant.RedisKeyConstant.STOCK_MSG_COOKIE_EXPIRE;
import java.time.LocalDate;
import java.util.Map;

import static cemp.redis.constant.RedisKey.STOCK_CURRENT_STATUS;

@Component
@Slf4j
public class CookieExpireListner {

    @Autowired
    RedisUtils redisUtils;

    @KafkaListener( topics = "cookie_expire",groupId = "${spring.kafka.consumer-group}")
    public void  expireCookie(String msg){
        //写redis
        LocalDate date =  DateUtil.str2LocalDate(msg);
        date = date.plusDays(5);        //5天后设置为过期时间
        redisUtils.set(STOCK_MSG_COOKIE_EXPIRE,DateUtil.localDate2Str(date));
    }
}
